home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PRUS101.ZIP / FDOS.PAS < prev    next >
Pascal/Delphi Source File  |  1994-12-19  |  6KB  |  203 lines

  1. Unit FDOS; { FIDO unit for DOS related stuff }
  2.  (***************************************************************************
  3.  
  4.           RELEASE 1.02 - as first included in the file PRUS101.LZH
  5.                 by Orazio Czerwenka, 2:2450/540.55, GERMANY
  6.  
  7.                --------------------------------------------
  8.                 organized for Fido's PASCAL related echoes    
  9.                --------------------------------------------
  10.  
  11.      05/22/1994 to --/--/---- by Orazio Czerwenka, 2:2450/540.55, GERMANY
  12.  
  13.  
  14.            As far as third party copyrights are not violated this
  15.            source code is hereby placed to the public domain. Use
  16.            it whatever way you want, but use AT YOUR OWN RISK.
  17.  
  18.            In case you should modify the source rather send your
  19.            modifications to the unit's current organizer (see above for
  20.            NM address) than to spread it on your own. This will help to
  21.            keep the unit updated and grant a certain standard to all
  22.            other users as well.
  23.  
  24.            The unit is currently still under work. So it might greatly
  25.            benefit of your participation.
  26.  
  27.            Those who contributed to the following piece of source,
  28.            listed in alphabethical order:
  29.         ================================================================
  30.            Andrew Eigus, Keld R. Hansen ...
  31.         ================================================================
  32.            YOUR NAME WILL APPEAR HERE IF YOU CONTRIBUTE USEFUL SOURCE.
  33.  
  34.            Credits in your own programs are as welcome as unnecessary.
  35.  
  36.          Special thanks to Andrew Eigus (2:5100/33, Latvia) who greatly
  37.           supported this piece of source by contributing a special PD
  38.                          version of his Unit ENHDOS.
  39.  
  40.  ***************************************************************************)
  41.  
  42. {$I FDEFINE.DEF}
  43.  
  44. interface
  45.  
  46. uses
  47.   dos,
  48.   FSTR                  { EnsureBackSlash for FileOnPath }
  49.   ;
  50.  
  51. const
  52.   { Error handler function (fr) result codes }
  53.  
  54.   frOk    = 0; { Continue program }
  55.   frRetry = 1; { Retry function once again }
  56.  
  57.   { Function codes (only passed to error handler routine) (fn) constants }
  58.  
  59.   fnGetDPB         = $3200;
  60.   fnGetDiskSize    = $3600;
  61.   fnGetDiskFree    = $3601;
  62.   fnGetCountryInfo = $3800;
  63.   fnSetDate        = $2B00;
  64.   fnSetTime        = $2D00;
  65.   fnIsFixedDrive   = $4408;
  66.   fnIsNetworkDrive = $4409;
  67.   fnCreateDir      = $3900;
  68.   fnRemoveDir      = $3A00;
  69.   fnGetCurDir      = $4700;
  70.   fnSetCurDir      = $3B00;
  71.   fnDeleteFile     = $4100;
  72.   fnRenameFile     = $5600;
  73.   fnGetFileAttr    = $4300;
  74.   fnSetFileAttr    = $4301;
  75.   fnFindFirst      = $4E00;
  76.   fnFindNext       = $4F00;
  77.   fnCreateFile     = $5B00;
  78.   fnCreateTempFile = $5A00;
  79.   fnOpenFile       = $3D00;
  80.   fnDupHandle      = $4500;
  81.   fnForceDup       = $4600;
  82.   fnRead           = $3F00;
  83.   fnWrite          = $4000;
  84.   fnFlush          = $6800;
  85.   fnSeek           = $4200;
  86.   fnGetFDateTime   = $5700;
  87.   fnSetFDateTime   = $5701;
  88.   fnCloseFile      = $3E00;
  89.   fnMemAlloc       = $4800;
  90.   fnMemFree        = $4900;
  91.   fnMemRealloc     = $4A00;
  92.  
  93.   { DOS 3.x+ errors/return codes }
  94.  
  95.   dosrOk                = 0;     { Success }
  96.   dosrInvalidFuncNumber = 1;     { Invalid DOS function number }
  97.   dosrFileNotFound      = 2;     { File not found }
  98.   dosrPathNotFound      = 3;     { Path not found }
  99.   dosrTooManyOpenFiles  = 4;     { Too many open files }
  100.   dosrFileAccessDenied  = 5;     { File access denied }
  101.   dosrInvalidFileHandle = 6;     { Invalid file handle }
  102.   dosrMemCtlBlksKilled  = 7;     { Memory control blocks destroyed }
  103.   dosrNotEnoughMemory   = 8;     { Not enough memory }
  104.   dosrInvalidEnvment    = 10;    { Invalid environment }
  105.   dosrInvalidFormat     = 11;    { Invalid format }
  106.   dosrInvalidAccessCode = 12;    { Invalid file access code }
  107.   dosrInvalidDrive      = 15;    { Invalid drive number }
  108.   dosrCantRemoveDir     = 16;    { Cannot remove current directory }
  109.   dosrCantRenameDrives  = 17;    { Cannot rename across drives }
  110.   dosrNoMoreFiles       = 18;    { No more files }
  111.   dosrFCB29Error        = $FF29; { Fn 29h: Invalid drive ID in filespec }
  112.   dosrFCB11Error        = $FF11; { Fn 11h: No matching files }
  113.  
  114. type
  115.   { Error handler function }
  116.  
  117.   TErrorFunc = function(ErrCode : integer; FuncCode : word) : byte;
  118.  
  119. var
  120.   DOSResult : integer; { Error status variable }
  121.  
  122. function execute(Name : PathStr ; Tail : ComSTR) : Word;
  123.  
  124. {$I FFILES.DEC}
  125. {$I FDRIVES.DEC}
  126.  
  127. implementation
  128.  
  129. var
  130.   ErrorHandler : TErrorFunc;
  131.  
  132. { -------------------------------------------------------------------------- }
  133.  
  134. PROCEDURE ReallocateMemory(P : POINTER); ASSEMBLER;
  135. ASM                                                { used by Execute }
  136.   MOV  AX, PrefixSeg
  137.   MOV  ES, AX
  138.   MOV  BX, WORD PTR P+2
  139.   CMP  WORD PTR P,0
  140.   JE   @OK
  141.   INC  BX
  142.  
  143.  @OK:
  144.   SUB  BX, AX
  145.   MOV  AH, 4Ah
  146.   INT  21h
  147.   JC   @X
  148.   LES  DI, P
  149.   MOV  WORD PTR HeapEnd,DI
  150.   MOV  WORD PTR HeapEnd+2,ES
  151.  
  152.  @X:
  153. END;
  154.  
  155. FUNCTION EXECUTE(Name : PathStr ; Tail : ComSTR) : WORD; ASSEMBLER;
  156. { Original author: Keld R. Hansen }
  157. ASM
  158.   {$IFDEF CPU386}
  159.   DB      66h
  160.   PUSH    WORD PTR HeapEnd
  161.   DB      66h
  162.   PUSH    WORD PTR Name
  163.   DB      66h
  164.   PUSH    WORD PTR Tail
  165.   DB      66h
  166.   PUSH    WORD PTR HeapPtr
  167.   {$ELSE}
  168.   PUSH    WORD PTR HeapEnd+2
  169.   PUSH    WORD PTR HeapEnd
  170.   PUSH    WORD PTR Name+2
  171.   PUSH    WORD PTR Name
  172.   PUSH    WORD PTR Tail+2
  173.   PUSH    WORD PTR Tail
  174.   PUSH    WORD PTR HeapPtr+2
  175.   PUSH    WORD PTR HeapPtr
  176.   {$ENDIF}
  177.   CALL ReallocateMemory
  178.   CALL SwapVectors
  179.   CALL DOS.EXEC
  180.   CALL SwapVectors
  181.   CALL ReallocateMemory
  182.   MOV  AX, DosError
  183.   OR   AX, AX
  184.   JNZ  @OUT
  185.   MOV  AH, 4Dh
  186.   INT  21h
  187.  
  188.  @OUT:
  189. END;
  190.  
  191. { -------------------------------------------------------------------------- }
  192.  
  193. {$I FFILES.INC}
  194. {$I FDRIVES.INC}
  195.  
  196. { -------------------------------------------------------------------------- }
  197.  
  198.  
  199. {$IFnDEF OVERLAYS}
  200. BEGIN
  201. {$ENDIF}
  202.  
  203. END.